
var util = require('../../utils/util.js')
const config = require('../../utils/config.js');
var my = require("../../utils/request.js");
Page({

  /**
     * 页面的初始数据
     */
    data: {

      //接口地址
     ActivityList: "activity/list",
     ActivitymsList: "activity/ms/list",
     activea:"active",
     activeb:" ",
     activityList:[]
    },
  
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
     var that=this
     if (that.data.activea = "active"){
        that.getActivityList();
    }else{
       that.getActivitymsList();
    }
      
    },
    //获取活动列表
    getActivityList:function(){
      var that=this;
      my.request({
        url:that.data.ActivityList,
        //data: params,
        method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        }, 
        success: function(res){

          console.log(res)
           that.setData({
            "activityList":res.data.data
           })
        }
  
      })
  
    },
    getActivitymsList:function(){
      var that = this;
      my.request({
        url: that.data.ActivitymsList,
        //data: params,
        method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        success: function (res) {

          console.log(res)
          that.setData({
            "activityList": res.data.data
          })
        }

      })

    },

    allActive:function(){
      var that=this;
      that.setData({
        "activea":"active",
        "activeb":""
       })
      that.getActivityList();
      wx.showToast({
        title: '加载中',
        icon: 'loading',
        duration: 500
      }) 
    },
    ReActivea:function(){
      var that=this;
      that.setData({
        "activeb":"active",
        "activea":""
       })
      that.getActivitymsList();
      wx.showToast({
        title: '加载中',
        icon: 'loading',
        duration: 500
      }) 
    },
    //跳转到详情
    activeDetail:function(e){
      var hid = e.currentTarget.dataset.hid
      console.log(e.currentTarget.dataset.hid)
      wx.navigateTo({
        url: '../detail/detail?hid=' + hid
      });
    },
  
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
    
    },
  
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
    
    },
  
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
    
    },
  
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
    
    },
  
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
    
    },
  
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
    
    },
  
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
    
    }
  })